package game.model;

/**
 * @author Amal Al-Ashour
 * Class Board stores information about a game board
 */

public class Board {
	private int rows; // number of rows
	private int cols; // number of columns
	private Block[][] grid; // the board grid
	
	/** Constructor */
	public Board(int rows, int cols){
		this.rows = rows;
		this.cols = cols;
		grid = new Block[rows][cols];
	}
	
	/** Return the number of rows in the board */
	public int getNumRows(){
		return rows;
	}
	
	/** Return the number of columns in the board */
	public int getNumColumns(){
		return cols;
	}
	
	/** Add a block at specified row and column coordinate */
	public void addBlock(int row, int col, Block block){
		if (row < 0 || row >= rows || col < 0 || col >= cols)
			return;
		grid[row][col] = block;
	}
	
	/** Get a block at specified row and column coordinate */
	public Block getBlock(int row, int col){
		if (row < 0 || row >= rows || col < 0 || col >= cols)
			return null;
		return grid[row][col];
	}
	
	/** Remove the block at specified row and column coordinate */
	public void removeBlock(int row, int col){
		if (row < 0 || row >= rows || col < 0 || col >= cols)
			return;
		grid[row][col] = null;
	}
	
}